# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=csfml
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.5
pkgrel=1
pkgdesc="A simple, fast, cross-platform, and object-oriented multimedia API for C (mingw-w64)"
arch=('any')
url="https://github.com/SFML/CSFML"
license=("zlib")
depends=("${MINGW_PACKAGE_PREFIX}-sfml")
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-doxygen")
source=("${_realname}-${pkgver}.tar.gz"::https://github.com/SFML/CSFML/archive/${pkgver}.tar.gz
        mingw-w64-msys2.patch)
sha256sums=('ccf38b057f3c306a731edc4e9e5b41a0f06105a4ea624ff42868c5b31983720e'
            'f052dd44659cf50f1645e2a99ce4e9c7f59b8aa2ac7017287394d8a0672011db')

prepare() {
  cd ${srcdir}/CSFML-${pkgver}
  patch -p1 -i ${srcdir}/mingw-w64-msys2.patch
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -r build-${MINGW_CHOST}
  mkdir build-${MINGW_CHOST} && cd build-${MINGW_CHOST}

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DCSFML_LINK_SFML_STATICALLY=OFF \
    -DBUILD_SHARED_LIBS=ON \
    -DCSFML_BUILD_DOC=ON \
    ../CSFML-${pkgver}

  make
  make doc
}

package() {
  cd build-${MINGW_CHOST}
  make DESTDIR=${pkgdir} install

  install -Dm644 ${srcdir}/CSFML-${pkgver}/license.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
} 
